package org.com.Controller;


import Entity.Voucher;
import jakarta.servlet.http.HttpServletRequest;
import org.com.Service.IVoucherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 277
 * @since 2025-09-17
 */
///api/voucher/seckill
@RestController
@RequestMapping("/voucher")
public class VoucherController {
    @Autowired
    private IVoucherService voucherService;

    @PostMapping("/add")
    public Voucher add(@RequestBody Voucher voucher) {

        return voucherService.saveWithRedis(voucher);
    }

    @GetMapping("/seckill")
    public List<Voucher> getSeckillVoucherById() {
        return voucherService.list();
    }

    @PostMapping("/seckill/{id}")
    public String seckillbyid(@PathVariable("id") int voucherid) throws InterruptedException {
        return voucherService.seckillbyid(voucherid);
    }
}
